package com.mixsmart.spellsql.order;

import com.mixsmart.spellsql.ICondition;
import com.mixsmart.spellsql.IOrder;

/**
 * 排序
 * @author lmq
 * @version 1.0
 * @since 1.0
 */
public class Order extends CompositeOrder {

	protected final String ORDER_KEY = " order by ";
	
	private ICondition condition;
	
	private IOrder order;

	public Order(ICondition condition,IOrder order) {
		this.condition = condition;
		this.order = order;
	}
	
	@SuppressWarnings("unchecked")
	@Override
	public String build() {
		String key = ORDER_KEY;
		if(this.condition instanceof  IOrder) {
			key = ",";
		}
		String conditionStr = this.condition.build()+key+order.build();
		super.addParameter(condition, order);
		return conditionStr;
	}
	
}
